<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>出借人信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>出借人</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="chuer" class="layui-input chuer" onclick="openPage('../public/choose_dealcom.php?dom=chuer&page=hou_jie_chuer','80%','80%')">
                            <div class="choose_div" id="chuer" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=chuer&page=hou_jie_chuer','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="chu_ming" class="layui-input chu_ming" onclick="choose_dealcom_zheng_by_chuer()">
                            <div class="choose_div" id="chu_ming" key="0"></div>
                            <span class="choose_one" onclick="choose_dealcom_zheng_by_chuer()"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="chu_bian" id="chu_bian" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="chu_tel" id="chu_tel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">住址/住所</label>
                        <div class="layui-input-block">
                            <input type="text" name="chu_addr" id="chu_addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>借款人信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>借款人</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="jieer" class="layui-input jieer" onclick="openPage('../public/choose_dealcom.php?dom=jieer&page=hou_jie_jieer','80%','80%')">
                            <div class="choose_div" id="jieer" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=jieer&page=hou_jie_jieer','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="jie_ming" class="layui-input jie_ming" onclick="choose_dealcom_zheng_by_jieer()">
                            <div class="choose_div" id="jie_ming" key="0"></div>
                            <span class="choose_one" onclick="choose_dealcom_zheng_by_jieer()"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="jie_bian" id="jie_bian" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="jie_tel" id="jie_tel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">住址/住所</label>
                        <div class="layui-input-block">
                            <input type="text" name="jie_addr" id="jie_addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>担保人信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">担保人1</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="daner" class="layui-input daner" onclick="openPage('../public/choose_dealcom.php?dom=daner&page=hou_jie_daner','80%','80%')">
                            <div class="choose_div" id="daner" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=daner&page=hou_jie_daner','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dan_ming" class="layui-input dan_ming" onclick="choose_dealcom_zheng_by_daner()">
                            <div class="choose_div" id="dan_ming" key="0"></div>
                            <span class="choose_one" onclick="choose_dealcom_zheng_by_daner()"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="dan_bian" id="dan_bian" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="dan_tel" id="dan_tel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">住址/住所</label>
                        <div class="layui-input-block">
                            <input type="text" name="dan_addr" id="dan_addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">担保人2</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="twoer" class="layui-input twoer" onclick="openPage('../public/choose_dealcom.php?dom=twoer&page=hou_jie_twoer','80%','80%')">
                            <div class="choose_div" id="twoer" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=twoer&page=hou_jie_twoer','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="two_ming" class="layui-input two_ming" onclick="choose_dealcom_zheng_by_twoer()">
                            <div class="choose_div" id="two_ming" key="0"></div>
                            <span class="choose_one" onclick="choose_dealcom_zheng_by_twoer()"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">证件编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="two_bian" id="two_bian" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="two_tel" id="two_tel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">住址/住所</label>
                        <div class="layui-input-block">
                            <input type="text" name="two_addr" id="two_addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>




            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits">
                        <span>借款信息</span>
                        <span class="lijigui colorhong float-r" style="margin-right: 15px">利息计算规则</span>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" id="number" readonly placeholder="系统自动生成编号" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>借款金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="money" name="money" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>签章状态</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state" ></select>
                            <p class="error" id="state_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>签章类型</label>
                        <div class="layui-input-block">
                            <select id="qiantype" name="qiantype" lay-filter="qiantype" ></select>
                            <p class="error" id="qiantype_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>签订日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="qiandt" id="qiandt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同份数</label>
                        <div class="layui-input-block">
                            <input type="number" name="henum" id="henum" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>借款用途</label>
                        <div class="layui-input-block ">
                            <input type="text" name="yong" id="yong" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>周期利率(%)</label>
                        <div class="layui-input-block">
                            <input type="number" id="yuerate" name="yuerate" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">借款起始日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="startdt" id="startdt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">借款终止日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="enddt" id="enddt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>出款方式</label>
                        <div class="layui-input-block">
                            <div id="fangtype"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">还款方式说明</label>
                        <div class="layui-input-block">
                            <textarea id="huanshuo" name="huanshuo" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>





            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>出借人账户信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">账户名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="chu_hu" name="chu_hu" clearable placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">开户行</label>
                        <div class="layui-input-block">
                            <input type="text" id="chu_kai" name="chu_kai" clearable placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">账号</label>
                        <div class="layui-input-block">
                            <input type="text" id="chu_hao" name="chu_hao" clearable placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>




            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联流程</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>

        <div class="block-generic">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="1">
                    <div class="opt-btn-group">
                        <div><span>收款人信息</span></div>
                        <div>
                            <button type="button" onclick="choose_dealcom_fuer()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">从往来单位选择</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th><text>*</text>收款人名称</th>
                            <th><text>*</text>账户名称</th>
                            <th>账号</th>
                            <th>开户行</th>
                            <th><text>*</text>付款金额(元)</th>
                            <th>款项说明</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="list_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    var param_isturn = getQueryVariable('isturn') || 0;
    if(param_isturn > 0){
        $("#billzhan").remove();
        $("#billtutn").remove();
        $("#billsub").attr('isshen', 1);
    }
    var param_billyushen = getQueryVariable('billyushen') || 0;
    if(param_billyushen == 2){
        $("#billyushen").addClass('layui-hide');
    }


    $("#commentForm").validate({
        rules: {
            jie_tel: {required: true},
            money: {required: true},
            yong: {required: true},
            yuerate: {required: true},
            qiandt: {required: true},
        },
        messages:{
            jie_tel: {required: "请输入"},
            money: {required: "请输入"},
            yong: {required: "请输入"},
            yuerate: {required: "请输入"},
            qiandt: {required: "请选择"},
        }
    });


    function choose_dealcom_fuer(){
        openPage('../public/choose_dealcom.php?page=hou_jie_fuer&choose_type=checkbox','80%','80%');
    }

    function choose_dealcom_bank_fuer(obj){
        var domkey = $(obj).parents('tr').index();
        var name = $(obj).parents('tr').find('.fuer').val() || '';
        if(!name){
            facade.error("请先选择收款人名称");return false;
        }
        openPage('../public/choose_dealcom_bank.php?page=hou_jie_fuer&name='+encodeURI(name)+'&domkey='+domkey,'80%','80%');
    }

    function choose_dealcom_zheng_by_chuer(){
        var name = get_choose_val('chuer');
        if(!name){
            facade.error("请先选择出借人");return false;
        }
        openPage('../public/choose_dealcom_zheng.php?page=hou_jie_chuer&name='+encodeURI(name),'80%','80%');
    }
    function choose_dealcom_zheng_by_jieer(){
        var name = get_choose_val('jieer');
        if(!name){
            facade.error("请先选择借款人");return false;
        }
        openPage('../public/choose_dealcom_zheng.php?page=hou_jie_jieer&name='+encodeURI(name),'80%','80%');
    }
    function choose_dealcom_zheng_by_daner(){
        var name = get_choose_val('daner');
        if(!name){
            facade.error("请先选择担保人1");return false;
        }
        openPage('../public/choose_dealcom_zheng.php?page=hou_jie_daner&name='+encodeURI(name),'80%','80%');
    }
    function choose_dealcom_zheng_by_twoer(){
        var name = get_choose_val('twoer');
        if(!name){
            facade.error("请先选择担保人2");return false;
        }
        openPage('../public/choose_dealcom_zheng.php?page=hou_jie_twoer&name='+encodeURI(name),'80%','80%');
    }

    function choose_dealcom_bank_shou(){
        var name = get_choose_val('jieer');
        if(!name){
            facade.error("请先选择借款人");return false;
        }
        openPage('../public/choose_dealcom_bank.php?page=hou_jie_shou&name='+encodeURI(name),'80%','80%');
    }

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();



        facade.ajax({type: 'get', url: ask_flowdata_edit_hou_jie, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                    if(data.advaners_info.length > 0){
                        tan_tags_init('#advaners', data.advaners_info);
                    }
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                    if(data.nexter_info.length > 0){
                        tan_tags_init('#nexter', data.nexter_info);
                    }
                }
                if(data.flowrelas_info.length > 0){
                    set_choose_btn_more('flowrelas',data.flowrelas_info);
                }


                $("#chu_bian").val(data.chu_bian);
                $("#chu_tel").val(data.chu_tel);
                $("#chu_addr").val(data.chu_addr);
                $("#jie_bian").val(data.jie_bian);
                $("#jie_tel").val(data.jie_tel);
                $("#jie_addr").val(data.jie_addr);
                $("#dan_bian").val(data.dan_bian);
                $("#dan_tel").val(data.dan_tel);
                $("#dan_addr").val(data.dan_addr);
                $("#two_bian").val(data.two_bian);
                $("#two_tel").val(data.two_tel);
                $("#two_addr").val(data.two_addr);
                $("#money").val(data.money);
                $("#yong").val(data.yong);
                $("#yuerate").val(data.yuerate);
                $("#number").val(data.number);
                $("#qiandt").val(data.qiandt);
                $("#henum").val(data.henum);
                $("#startdt").val(data.startdt);
                $("#enddt").val(data.enddt);
                $("#huanshuo").val(data.huanshuo);
                $("#chu_hu").val(data.chu_hu);
                $("#chu_hao").val(data.chu_hao);
                $("#chu_kai").val(data.chu_kai);
                $("#explain").val(data.explain);


                if(data.chuer){
                    set_choose_btn('chuer',data.chuer,data.chuer);
                }
                if(data.chu_ming){
                    set_choose_btn('chu_ming',data.chu_ming,data.chu_ming);
                }

                if(data.jieer){
                    set_choose_btn('jieer',data.jieer,data.jieer);
                }
                if(data.jie_ming){
                    set_choose_btn('jie_ming',data.jie_ming,data.jie_ming);
                }

                if(data.daner){
                    set_choose_btn('daner',data.daner,data.daner);
                }
                if(data.dan_ming){
                    set_choose_btn('dan_ming',data.dan_ming,data.dan_ming);
                }

                if(data.twoer){
                    set_choose_btn('twoer',data.twoer,data.twoer);
                }
                if(data.two_ming){
                    set_choose_btn('two_ming',data.two_ming,data.two_ming);
                }


                xmselect_dan('fangtype', res.data.fangtype, data.fangtype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#fangtype").find('xm-select').removeClass('error');
                    }else{
                        $("#fangtype").find('xm-select').addClass('error');
                    }
                });

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(data.state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else{
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }
                }
                $("#state").html(state_str);

                var qiantype_str = '<option value="">请选择</option>';
                var qiantype = res.data.qiantype;
                for (var key in qiantype){
                    if(data.qiantype == qiantype[key]){
                        qiantype_str += '<option value="'+qiantype[key]+'" selected>'+qiantype[key]+'</option>';
                    }else{
                        qiantype_str += '<option value="'+qiantype[key]+'">'+qiantype[key]+'</option>';
                    }
                }
                $("#qiantype").html(qiantype_str);


                short_table_opt_func('', 1);


                var list = res.data.list;
                if(list.length > 0){
                    for (var key in list){
                        var str = '';
                        var nums = parseInt(key)+1;
                        str += '<tr>';
                        str += '<td style="width: 45px">'+nums+'</td>';
                        str += '<td><input type="text"  value="'+list[key].fuer+'" readonly class="layui-input fuer disabled"></td>';
                        str += '<td><input type="text" onclick="choose_dealcom_bank_fuer(this)" value="'+list[key].bankzhang+'" readonly class="layui-input bankzhang disabled"></td>';
                        str += '<td><input type="text" value="'+list[key].banknum+'" disabled class="layui-input banknum disabled"></td>';
                        str += '<td><input type="text" value="'+list[key].bankname+'" disabled class="layui-input bankname disabled"></td>';
                        str += '<td><input type="number" value="'+list[key].money+'" class="layui-input money"></td>';
                        str += '<td><input type="text" class="layui-input explain" value="'+list[key].explain+'"></td>';
                        str += '</tr>';
                        $("#list_list").append(str);
                        update_refresh_row_func()
                    }
                }

                public_upload_file_load('upload_files', res.data.files);
                initParseMoney();
                render_from();
            }
        });

        form.on('select(state)', function(data){
            if(data.value == ''){
                $('#state_error').show().text('请选择');
                $('#state_error').parent().find('input').addClass('select_error');
            }else{
                $('#state_error').hide();
                $('#state_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(qiantype)', function(data){
            if(data.value == ''){
                $('#qiantype_error').show().text('请选择');
                $('#qiantype_error').parent().find('input').addClass('select_error');
            }else{
                $('#qiantype_error').hide();
                $('#qiantype_error').parent().find('input').removeClass('select_error');
            }
        });


        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.isshen = $(this).attr('isshen') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');

            data.field.chuer = get_choose_val('chuer');
            data.field.chu_ming = get_choose_val('chu_ming');

            data.field.jieer = get_choose_val('jieer');
            data.field.jie_ming = get_choose_val('jie_ming');

            data.field.daner = get_choose_val('daner');
            data.field.dan_ming = get_choose_val('dan_ming');

            data.field.twoer = get_choose_val('twoer');
            data.field.two_ming = get_choose_val('two_ming');

            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                formValid('chuer');
                if(data.field.chuer == undefined || !data.field.chuer){
                    validRes = false;
                }
                formValid('jieer');
                if(data.field.jieer == undefined || !data.field.jieer){
                    validRes = false;
                }


                if(!data.field.fangtype){
                    $("#fangtype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#fangtype").find('xm-select').removeClass('error');
                }

                if(data.field.state == ''){
                    $('#state_error').show().text('请选择');
                    $('#state_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#state_error').hide();
                    $('#state_error').parent().find('input').removeClass('select_error');
                }


                if(data.field.qiantype == ''){
                    $('#qiantype_error').show().text('请选择');
                    $('#qiantype_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#qiantype_error').hide();
                    $('#qiantype_error').parent().find('input').removeClass('select_error');
                }

                if(!validRes){return false;}
            }


            var list = [''];
            try {
                $('#list_list tr').each(function (i) {
                    var fuer = $(this).find('.fuer').val();
                    var bankzhang = $(this).find('.bankzhang').val();
                    var banknum = $(this).find('.banknum').val();
                    var bankname = $(this).find('.bankname').val();
                    var money = $(this).find('.money').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){
                        if(!fuer){
                            throw new Error('第'+index+'行，请选择收款人名称');
                        }
                        if(!bankzhang){
                            throw new Error('第'+index+'行，请选择账户');
                        }
                        if(money == ''){
                            throw new Error('第'+index+'行，请输入打款金额');
                        }
                    }


                    list.push({
                        fuer:fuer,
                        money:money,
                        bankzhang:bankzhang,
                        banknum:banknum,
                        bankname:bankname,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".listerror").find('span').text(e.message);
                $(".listerror").show();
                return false;
            }
            $(".listerror").hide();
            data.field.list = list;


            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);
            public_flow_submit(data.field, ask_flowdata_add_hou_jie, ask_flowdata_edit_hou_jie, $(this).attr('but'));
            return false;
        });

    });


    $(".lijigui").hover(function(){
        var tipsStr = '利息计算规则：'+'<br>';
        tipsStr += '1. 借款利率： 2 % / 一个周期（一个周期为30天）。'+'<br>';
        tipsStr += '2.计息方式'+'<br>';
        tipsStr += '2.1 利息计算公式：利息=借款本金*借款利率*（周期数+余天数/30）；'+'<br>';
        tipsStr += '2.2 计息规则：'+'<br>';
        tipsStr += '2.1.1 总借款天数自甲方实际支付借款之日起计算，至乙方偿还借款本金之日止；'+'<br>';
        tipsStr += '2.1.2 周期数=总借款天数/30的整数部分；'+'<br>';
        tipsStr += '2.1.3 余天数=总借款天数-周期数*30；'+'<br>';
        tipsStr += '①余天数不足10日的：余天数=实际天数；'+'<br>';
        tipsStr += '②余天数超过10日的：余天数=30；'+'<br>';
        tipsStr += '备注：'+'<br>';
        tipsStr += '本条“不足10日”不包含10日，“超过10日”包含10日。'+'<br>';
        tipsStr += '2.3 借款期限届满乙方须继续使用借款本金的，甲方以未还本金为基数，按本合同第四条'+'<br>';
        tipsStr += '约定的计息方式重新计息。'+'<br>';
        hhzhu_index = layer.tips(tipsStr,this,{time:0,area: ['500px', 'auto']});
    },function(){layer.close(hhzhu_index);});



    function choose_jieer_delete() {
        $("#jie_ming").html('');
        $("#jie_bian").val('');
        $("#jie_tel").val('');
        $("#jie_addr").val('');
    }

    function choose_daner_delete() {
        $("#dan_ming").html('');
        $("#dan_bian").val('');
        $("#dan_tel").val('');
        $("#dan_addr").val('');
    }

    function choose_twoer_delete() {
        $("#two_ming").html('');
        $("#two_bian").val('');
        $("#two_tel").val('');
        $("#two_addr").val('');
    }

    function update_refresh_row_func() {
        render_date();
        render_from();
        $.each($("#list_list").children('tr'),function (key,val) {
            $(this).children('td:first-child').html(key+1);
        });
        setTimeout(function () {
            $(".short_table_list table tbody tr").click(function () {
                $(".short_table_list table tbody tr").removeClass('line-row');
                $(".short_table_list table tbody tr").attr('sle','');
                $(this).addClass('line-row');
                $(this).attr('sle','sle');
            });
        },1000);
    }
</script>
</body>
</html>
